<?php
/**
 * Created by JetBrains PhpStorm.
 * File: MenuItemModel.class.php
 * User: Xnfy520@gmail.com
 * Date: 12-3-16
 * Time: 下午4:12
 */

	class MenuItemModel extends RelationModel{

		protected $_validate = array(
			array('name', 'require', '菜单项名称不能为空', 1),
			array('link', 'require', '链接地址不能为空', 1),
		);

		protected $_auto = array(
			array('path', '_getpath', 3, 'callback'),
		);

		function _getpath(){
			$pid = isset($_POST['pid']) ? $_POST['pid'] : 0;
			if($pid==0){
				return 0;
			}else{
				$id = $_POST['id'];
			//	$oinfo = $this->find($id);
				$pinfo = $this->find($pid);
			//	if($_POST['pid']==$_POST['id']){
			//		$path =  $oinfo['path'];
		//		}else{
					$path = $pinfo['path'].'-'.$pinfo['id'];
		//		}
				return $path;
			}

		}

	}